import { RMIErrorCode } from "../../../Engine/error/RMIErrorCode";
import { SystemErrorCode } from "../../../Engine/error/SystemErrorCode";
// import { ErrorCodeConfig } from "../../game/resource/ErrorCodeConfig";
import { PreLanguage } from "../../../extend/language/PreLanguage";
type int = number;
//class ErrorCode

export class ErrorCode {

  public static init(): void {
    new RMIErrorCode();
    ErrorCode.initRMIError();
    new SystemErrorCode();
    ErrorCode.initSystemErroe();
    return;
  }

  public static getErrorStringByCode(code: int) {
    if (SystemErrorCode.isInError(code)) {
      return SystemErrorCode.getErrorByCode(code);
    }
    if (RMIErrorCode.isInError(code)) {
      return RMIErrorCode.getErrorByCode(code);
    }
    // return ErrorCodeConfig.instance.getErrorStringByCode(arg1);
  }

  public static getErrorByLogin(arg1: int): string {
    if (SystemErrorCode.isInError(arg1)) {
      return SystemErrorCode.getErrorByCode(arg1);
    }
    if (RMIErrorCode.isInError(arg1)) {
      return RMIErrorCode.getErrorByCode(arg1);
    }
    return arg1 + "";
  }

  /* internal  */ static initRMIError(): void {
    var loc1 = RMIErrorCode.map;
    loc1[RMIErrorCode.ExceptionCodeRMI] = PreLanguage.getString(127);
    loc1[RMIErrorCode.ExceptionCodeNotSupported] = PreLanguage.getString(128);
    loc1[RMIErrorCode.ExceptionCodeInvoke] = PreLanguage.getString(129);
    loc1[RMIErrorCode.ExceptionCodeTimeOut] = PreLanguage.getString(130);
    loc1[
      RMIErrorCode.ExceptionCodeConnectionNotConnect
    ] = PreLanguage.getString(131);
    loc1[RMIErrorCode.ExceptionCodeConnectionClosed] = PreLanguage.getString(
      132
    );
    loc1[RMIErrorCode.ExceptionCodeConnectionWrite] = PreLanguage.getString(
      133
    );
    loc1[RMIErrorCode.ExceptionCodeObjectNotExist] = PreLanguage.getString(134);
    loc1[RMIErrorCode.ExceptionCodeOperationNotExist] = PreLanguage.getString(
      135
    );
    loc1[RMIErrorCode.ExceptionCodeNotInstantiation] = PreLanguage.getString(
      136
    );
    loc1[RMIErrorCode.ErrorDb_PlayerIdError] = PreLanguage.getString(137);
    loc1[
      RMIErrorCode.ErrorDb_PlayerCreateUserNameExsit
    ] = PreLanguage.getString(138);
    loc1[
      RMIErrorCode.ErrorDb_PlayerCreateRoleNameExsit
    ] = PreLanguage.getString(139);
    loc1[RMIErrorCode.ErrorLogin_NeedLoginFromPlatform] = PreLanguage.getString(
      140
    );
    loc1[RMIErrorCode.ErrorLogin_NoRole] = PreLanguage.getString(141);
    loc1[RMIErrorCode.ErrorLogin_RoleNameIsToLong] = PreLanguage.getString(142);
    loc1[RMIErrorCode.ErrorLogin_CreateRoleNameError] = PreLanguage.getString(
      143
    );
    loc1[RMIErrorCode.ErrorLogin_CreateRoleDataError] = PreLanguage.getString(
      144
    );
    loc1[RMIErrorCode.ErrorLogin_UserNameError] = PreLanguage.getString(145);
    loc1[RMIErrorCode.ErrorGate_LoginNotLogin] = PreLanguage.getString(146);
    loc1[RMIErrorCode.ErrorGate_LoginIsLogin] = PreLanguage.getString(147);
    loc1[RMIErrorCode.ErrorGate_OperNotCD] = PreLanguage.getString(148);
    loc1[RMIErrorCode.ErrorLogin_ErrorCodeVersion] = PreLanguage.getString(149);
    return;
  }

  /* internal  */ static initSystemErroe(): void {
    var loc1 = SystemErrorCode.map;
    loc1[SystemErrorCode.ExceptionCodeUnkown] = PreLanguage.getString(116);
    loc1[SystemErrorCode.ExceptionOutOffMemery] = PreLanguage.getString(117);
    loc1[SystemErrorCode.ExceptionCodeBase] = PreLanguage.getString(118);
    loc1[SystemErrorCode.ExceptionCodeStd] = PreLanguage.getString(119);
    loc1[SystemErrorCode.ExceptionCodeDateTime] = PreLanguage.getString(120);
    loc1[SystemErrorCode.ExceptionCodeFunction] = PreLanguage.getString(121);
    loc1[SystemErrorCode.ExceptionCodeNullHandle] = PreLanguage.getString(122);
    loc1[SystemErrorCode.ExceptionCodeDB] = PreLanguage.getString(123);
    loc1[SystemErrorCode.ExceptionCodeSerialize] = PreLanguage.getString(124);
    loc1[SystemErrorCode.ExceptionCodeLang] = PreLanguage.getString(125);
    loc1[SystemErrorCode.ExceptionCodeXml] = PreLanguage.getString(126);
    return;
  }

  public static /* const */ ErrorLogin_NoRole: int = 33001;

  public static /* const */ ErrorCell_FightToEntityNotOnline: int = 38006;

  public static /* const */ ErroeCell_CollectToEntityNotOnline: int = 38050;

  public static /* const */ ErrorCell_ModeSetPeaceModeCdError: int = 38031;

  public static /* const */ ErrorPublic_CopyGroupNotExsit: int = 31255;

  public static /* const */ ErrorPublic_PlayerNotOnline: int = 40001;

  public static /* const */ ErrorCell_EscortIsAttacked: int = 38105;

  public static /* const */ ErrorCell_ObstructNotFight: int = 38034;

  public static /* const */ ErrorCell_CollectHasOwner: int = 38052;

  public static /* const */ ErrorGate_ZazenPlayerReject: int = 35852;

  public static /* const */ ErrorCell_FightTooFar: int = 38005;

  public static /* const */ ErrorCell_SkillTooFar: int = 38082;

  public static /* const */ ErrorCell_CollectDistanceTooFar: int = 38056;

  public static /* const */ ErrorCell_InputPointError: int = 38024;

  public static /* const */ ErrorGate_TransportHadTask: int = 35484;

  public static /* const */ ErrorGate_BagBagIsFull: int = 35340;

  public static /* const */ ErrorGate_BagSlotNotEnough: int = 35341;

  public static /* const */ ErrorGate_FriendFriendAmountLimite: int = 35267;

  public static /* const */ ErrorPublic_CannotGetPetCpnReward: int = 31686;
}
